import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { list2 } from '../TSubmission/TSubmission.api';
//列表数据
export const columns: BasicColumn[] = [
   // {
   //  title: '租户号',
   //  align:"center",
   //  dataIndex: 'tenantId'
   // },
   // {
   //  title: '检测机构',
   //  align:"center",
   //  dataIndex: 'testOrgId_dictText'
   // },
   {
    title: '检测类型',
    align:"center",
    dataIndex: 'type',
    customRender: (data) => {
      const typeArr = ['' ,'品质', '土壤']
      return typeArr[data.record.type];
    }
   },
   {
    title: '送检编号',
    align:"center",
    dataIndex: 'submissionNo'
   },
   {
    title: '样品名称',
    align:"center",
    dataIndex: 'bizName'
   },
   {
    title: '送检单位',
    align:"center",
    dataIndex: 'submissionOrg_dictText'
   },
   {
    title: '送检人',
    align:"center",
    dataIndex: 'submitter'
   },
   {
    title: '联系方式',
    align:"center",
    dataIndex: 'submitterContact'
   },
   {
    title: '送检时间',
    align:"center",
    dataIndex: 'submitDate',
    width: 170
   },
   // {
   //  title: '检测样品描述',
   //  align:"center",
   //  dataIndex: 'testSample'
   // },
   // {
   //  title: '送检日期',
   //  align:"center",
   //  dataIndex: 'submitDate'
   // },
   {
    title: '报告时间',
    align:"center",
    dataIndex: 'reportDate',
    width: 170
   },
   {
    title: '检测报告',
    align:"center",
    slots: { customRender: 'fileSlot' },
    dataIndex: 'report'
   },
   {
    title: '是否上链',
    align:"center",
    dataIndex: 'location',
    customRender:(data) =>{
      return data.record.cngData ? '已上链' : '未上链'
    },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  // {
  //   field: 'reportDate',
  //   component: 'RangePicker',
  //   label: '报告日期',
  //   componentProps: {
  //     valueType: 'Date',
  //   },
  //   colProps: {
  //     span: 8,
  //   },
  // },
];
//表单数据
export const formSchema: FormSchema[] = [
  // {
  //   label: '租户号',
  //   field: 'tenantId',
  //   component: 'Input',
  // },
  // {
  //   label: '检测时间',
  //   field: 'detectionDate',
  //   component: 'DatePicker',
  //   componentProps: {
  //      showTime: true,
  //      valueFormat: 'YYYY-MM-DD HH:mm:ss'
  //    },
  //   dynamicRules: ({model,schema}) => {
  //         return [
  //                { required: true, message: '请输入检测时间!'},
  //         ];
  //    },
  //    show: false
  // },
  {
    label: '检测编号',
    field: 'submissionId',
    component: 'ApiSelect',
    componentProps: {
      api: list2,
      resultField: 'records',
      labelField: 'submissionNo',
      valueField: 'id',
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入检测编号!'},
      ];
     },
  },
  {
    label: '样本名称',
    field: 'bizName',
    component: 'Input',
    dynamicDisabled: true
  },
  
  {
    label: '样本情况',
    field: 'sampleDescription',
    component: 'Input',
    dynamicDisabled: true
  },
  {
    label: '送检时间',
    field: 'submitDate',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
     dynamicDisabled: true
  },
  {
    label: '送检单位',
    field: 'submitter',
    component: 'Input',
    dynamicDisabled: true
  },
  {
    label: '报告时间',
    field: 'reportDate',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '检测报告',
    field: 'report',
    component: 'JUpload',
    componentProps: {
      
    }
  },
	// TODO 主键隐藏字段，目前写死为ID
	// {
	//   label: '',
	//   field: 'id',
	//   component: 'Input',
	//   show: false
	// },
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
